package code.codeworld.common.kits;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;

/**
 * @Description: 地址跳转工具
 * @Author: codeworld
 * @Date: 2023/03/23 00:20
 */
@Controller
@RequestMapping("/")
public class HtmlSkip {

    @RequestMapping("")
    public ModelAndView index(Model model) {
        model.addAttribute("msg", "<h1>templates测试</h1>");
        model.addAttribute("users", Arrays.asList("lishao", "liyuan"));
        String url = "redirect:http://localhost:8080/index.html";
        return new ModelAndView(url);
    }

    @RequestMapping("edit")
    public ModelAndView edit(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        String url = "redirect:http://localhost:8080/views/edit.html";
        return new ModelAndView(url);
    }

}
